package com.roc.jpamysql.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.roc.jpamysql.model.Film;
import com.roc.jpamysql.service.IFilmService;
import com.roc.jpamysql.service.impl.FilmServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author roc
 * @since 2024-03-22
 */
@RestController
@RequestMapping("/film")
@Api(tags = "电影模块")
public class FilmController {

    @Resource
    IFilmService filmService;


    @GetMapping("/getFilm")
    @ApiOperation(value = "获取电影",notes = "根据电影 id 获取电影")
    public Film getFilm(@RequestParam @ApiParam("电影 id") Integer filmId) {
        return filmService.getById(filmId);
    }

    @GetMapping("/getFilmList")
    @ApiOperation(value = "获取电影集合",notes = "获取所有")
    public Map<String, Object> getFilmList() {
        QueryWrapper<Film> filmQueryWrapper = new QueryWrapper<>();
        Map<String, Object> filmServiceMap = filmService.getMap(filmQueryWrapper);
        return filmServiceMap;
    }

}
